package com.example.demoback.mapper;

import com.example.demoback.entity.Category;
import com.example.demoback.entity.Item;
import com.example.demoback.entity.Subcategory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface TypeMapper {
    @Select("select * from category")
    List<Map<String, Object>> selectAll();

    @Select("select * from category where categoryname=#{categoryname}")
    Category selectByIdAndName(@Param("categoryname") String name);

    @Select("SELECT * FROM category")
    List<Category> selectAllCategories();

    @Select("SELECT * FROM subcategory WHERE categoryid = #{categoryid}")
    List<Subcategory> selectSubCategoriesByCategoryId(@Param("categoryid") int categoryId);

    @Select("select * from item where subcategoryid = #{subcategoryid}")
    List<Map<String, Object>> selectItemsBySubcategoryId(@Param("subcategoryid") int id);

    @Select("select * from item where subcategoryid = #{subcategoryid} and itemname like concat('%',#{itemname},'%')")
    List<Map<String, Object>> selectItemsBySubcategoryIdAndName(@Param("subcategoryid") int id , @Param("itemname") String name);
}
